<template>
	<view class="">
		<u-sticky>
			<view class="sticky">
				<u-tabs
					:list="list"
					name="name"
					:active-item-style="activeStyle"
					font-size="26"
					active-color="#2781A7"
					inactive-color="#666666"
					:is-scroll="false"
					:current="current"
					@change="change"
				></u-tabs>
			</view>
		</u-sticky>
		<s-pull-scroll ref="pullScroll" :pullDown="pullDown" :pullUp="loadData" :back-top="true" :headerHeight="50">
			<view class="">
				<view class="order-con" v-for="(item, index) in dataList" :key="index" @tap.stop="navTo(`/pages/order/orderdetails?id=${item.id}`)">
					<view class="order-top b-b row between">
						<view class="row">
							<view class="cart-item-img"><image src="/static/img/zuanyeqingxi.png" mode="aspectFill" class="img"></image></view>
							<view class="s-con">专业清洗</view>
						</view>
						<view class="order-status" v-if="item.status == 0">待付款</view>
						<view class="order-status" v-if="item.status == 1">已下单</view>
						<view class="order-status" v-if="item.status == 2">团长已收衣</view>
						<view class="order-status" v-if="item.status == 3">送往洗衣中心</view>
						<view class="order-status" v-if="item.status == 4">清洗中</view>
						<view class="order-status" v-if="item.status == 5">送回中</view>
						<view class="order-status" v-if="item.status == 6">团长已签收</view>
						<view class="order-status" v-if="item.status == 7">待评价</view>
						<view class="order-status" v-if="item.status == 8">已完成</view>
					</view>
					<view class="order-item-info">
						<view class="cart-item-title">订单编号：{{ item.orderNum }}</view>
						<view class="cart-item-title">下单时间：{{ item.createDate }}</view>

						<view class="row between">
							<view class="">
								<text class="cart-fee">
									订单金额：
									<text class="cart-money">{{ item.sum }}</text>
								</text>
							</view>
							<!-- "status":"0待付款1已下单2团长已收衣3送往洗衣中心4清洗中5送回中6团长已签收7待评价8已完成" -->
							<view class="row">
								<view class="order-btn one" v-if="item.status == 7" hover-class="hover-opacity" @tap.stop="navTo(`/pages/order/replayOrder?id=${item.id}`)">
									去评价
								</view>
								<view class="order-btn two" v-if="item.status==0" hover-class="hover-opacity" @tap.stop="navTo(`/pages/order/payorder?id=${item.id}&money=${item.sum}`)">去付款</view>
								<view class="order-btn one" v-if="item.status == 0" hover-class="hover-opacity" @tap.stop="cancelOrder">取消订单</view>
								<view class="order-btn one" v-if="item.status==8" hover-class="hover-opacity" @tap.stop="deleteOrder">删除订单</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</s-pull-scroll>
		<mix-loading v-if="isLoading"></mix-loading>
		<mix-modal :text="modalText" :title="modalTitle" ref="mixModal" :showCancle="true"></mix-modal>
	</view>
</template>

<script>
import orderMixins from '@/common/mixin/order.js';
export default {
	mixins: [orderMixins],
	data() {
		return {
			activeStyle: {
				color: '#000000'
			},
			list: [
				{
					name: '全部'
				},
				{
					name: '未完成'
				},
				{
					name: '已完成'
				},
				{
					name: '待评价'
				}
			],
			dataList: [],
			current: 0
		};
	},
	onLoad(options) {
		this.current = options.type;
		this.refresh();
	},
	methods: {
		change(index) {
			this.current = index;
			this.refresh();
		},
		pullDown(pullScroll) {
			setTimeout(() => {
				this.loadData(pullScroll);
			}, 200);
		},
		async loadData(pullScroll) {
			const data = {
				uid: uni.getStorageSync('uid'),
				pageNo: pullScroll.page,
				pageSize: '10'
			};
			const res = await this.$request('order/list', data, { showLoading: true });
			if (pullScroll.page == 1) this.dataList = [];
			if (res.result == 0) {
				this.dataList = this.dataList.concat(res.data.list);
				pullScroll.endByPage(Math.ceil(res.data.count / 10), res.data.list);
			} else {
				this.$util.msg(res.resultNote);
			}
		}
	}
};
</script>
<style>
page {
	background: #f6f6f6;
}
</style>

<style scoped lang="scss">
.order-con {
	background: #ffffff;
	border-radius: 20upx;
	width: 94%;
	margin: 0 auto;
	margin-bottom: 20upx;
	padding: 20upx;
}
.order-top {
	line-height: 70upx;
	padding-bottom: 20upx;
}
.s-con {
	font-size: 32upx;
	font-family: PingFang SC;
	font-weight: bold;
	color: #000000;
}
.order-status {
	font-size: 26upx;
	font-family: PingFang SC;
	font-weight: 500;
	color: #2781a7;
}
.order-item-info {
	padding: 20upx 0;
}
.cart-item-img {
	width: 62upx;
	height: 62upx;
	border-radius: 10upx;
	margin-right: 20rpx;
	position: relative;
}
.img {
	width: 62upx;
	height: 62upx;
}
.cart-item-title {
	font-size: 26upx;
	font-family: PingFang SC;
	font-weight: 500;
	color: #333333;
	line-height: 47upx;
}
.cart-item-price {
	font-size: 30upx;
	font-family: PingFang SC;
	font-weight: bold;
	color: #cb1414;
	line-height: 36upx;
}
.cart-fee {
	font-size: 27upx;
	font-family: PingFang SC;
	font-weight: 500;
	color: #fe2525;
}
.cart-money {
	color: #fe2525;
	font-size: 30upx;
	position: relative;
}
.cart-money::before {
	content: '￥';
	font-size: 20upx;
}
.order-btn {
	padding: 10upx 30upx;
	text-align: center;
	border-radius: 36upx;
	font-size: 26upx;
	font-family: PingFang SC;
	font-weight: 500;
}
.one {
	color: #666666;
	border: 1px solid #e7e7e7;
	
}
.two {
	color: #fe2525;
	border: 1px solid #fe2525;
	margin-right:10upx;
}
</style>
